﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
</head>
<body>

  <script>

    var result = [];
    for (var i = 0; i < 10; i++)
    {
      result[i] = (function() { var data = i; return function () { return data; } })();
    }

    alert( result[5]() );

  </script>

</body>
</html>
